Junaed/fssdk 12294 sync hook impl#321
Merged
junaed-optimizely merged 11 commits intomasterfrom Mar 13, 2026
Merged
Conversation
raju-opti
requested changes
Mar 13, 2026
Contributor
raju-opti
left a comment
There was a problem hiding this comment.
looks great. few small things commented
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New hooks
useDecide(flagKey, config?)— Returns a feature flag decision (decision, isLoading, error) for a given flag key. Subscribes to ProviderStateStore via useSyncExternalStore and re-evaluates when client readiness, user context, or forced decisions change.useOptimizelyClient()— Returns the Optimizely client instance from the nearest provider. Does not re-render on store state changes.useOptimizelyUserContext()— Returns the current OptimizelyUserContext (or null). Re-renders only when the user context reference changes, not on unrelated state changes.Supporting hooks/utilities
useOptimizelyContext()— Internal hook that reads React context and throws if used outside .useStableArray(arr)— Preserves referential identity for inline arrays (e.g. decideOptions) when elements are shallowly equal, preventing unnecessary re-evaluations.createDefaultDecision(flagKey)— Helper that produces a safe default OptimizelyDecision while loading or on error.ProviderStateStore changes
subscribeForcedDecision(flagKey, callback)— per-flag-key subscription so useDecide can react to forced decision changes without re-evaluating unrelated flags.Dependency changes
use-sync-external-store(with shim for React <18 compat)Tests
useDecide,useOptimizelyClient, anduseOptimizelyUserContextcovering loading states, error handling, reactivity, referential stability, subscription cleanup, and forced decision behavior.Issues